import java.util.Stack;

public class RealizeDequeByTwoStack {
    // 用栈实现两个队列
    // https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D295
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
        stack1.add(node);
    }

    public int pop() {
        int ret = 0;
        while (!stack1.isEmpty()) {
            stack2.add(stack1.pop());
        }
        ret = stack2.pop();
        while (!stack2.isEmpty()) {
            stack1.add(stack2.pop());
        }
        return ret;
    }
}
